//
//  STBuyCarListCell.m
//  CuiBoStore
//
//  Created by 崔博 on 16/12/13.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STBuyCarListCell.h"

@interface STBuyCarListCell()
@property (weak, nonatomic) IBOutlet UIButton *seletedBtn;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end

@implementation STBuyCarListCell


- (void)setBuyCarModel:(STBuyCarListModel *)buyCarModel
{
    _buyCarModel = buyCarModel;
    [_iconView downloadImage:buyCarModel.ImgView placeholder:nil];
    self.titleLabel.text = buyCarModel.GoodsTitle;
    self.priceLabel.text = [@(buyCarModel.Price) stringValue];
    self.seletedBtn.selected = buyCarModel.isSelectButton;
    self.countLabel.text = [@(buyCarModel.GoodsCount) stringValue];
}
// 选择按钮
- (IBAction)seletedClick:(UIButton *)sender {
    [self getSuperViewTag:sender block:self.seletedBlock];
}
// 加钱
- (IBAction)addBtn:(UIButton *)sender {
    [self getSuperViewTag:sender block:self.addBlock];
}
// 减钱
- (IBAction)reduceBtn:(UIButton *)sender {
   [self getSuperViewTag:sender block:self.reduceBlock];
}

- (void)getSuperViewTag:(UIButton *)btn block:(TagBlock)block;
{
    UIView *superView = [[btn superview] superview];
    if (block) {
        block(superView.tag - 1000);
    }
}

@end
